//
//  RHInvParamSelectItemCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2024/6/14.
//

#import "RHInvParamSelectItemCell.h"
@interface RHInvParamSelectItemCell()



@end
@implementation RHInvParamSelectItemCell

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

-(void)setItemModel:(RHInvParamModel *)itemModel
{
    _itemModel = itemModel;
    [self.btn setTitle:[NSString stringWithFormat:@"%@ %@",itemModel.keyName.rh_localized,itemModel.unit] forState:UIControlStateNormal];
    if(itemModel.isSelected){
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#05C79D" alpha:1] forState:UIControlStateNormal];
        [self.btn setBackgroundColor:kCOLOR_HEX_A(@"#05C79D",0.2)];
        [self.btn rounded:8 width:1 color:kCOLOR_HEX(@"#05C79D")];
    }else{
        [self.btn setTitleColor:[UIColor colorWithHexString:@"#6E7071" alpha:1] forState:UIControlStateNormal];
        [self.btn setBackgroundColor:kCOLOR_HEX(@"#FCFBFB")];
        [self.btn rounded:8 width:1 color:kCOLOR_HEX(@"#CDD0D6")];
    }
}

-(void)setupUI
{
    self.contentView.backgroundColor = UIColor.whiteColor;
    UIView *bgView = kView;
    bgView.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsMake(0, 0, 0, 0));
      
    }];
    
    _btn = [[QMUIButton alloc]init];
    _btn.userInteractionEnabled = NO;
    _btn.titleLabel.numberOfLines = 2;
    _btn.titleLabel.adjustsFontSizeToFitWidth = YES;
    _btn.titleLabel.minimumScaleFactor = 0.8;
    [_btn setCornerRadius:8];
    _btn.titleLabel.font = kSYSTEMFONT(12);
    _btn.contentEdgeInsets = UIEdgeInsetsMake(3, 3, 3, 3);
    [bgView addSubview:_btn];
    [_btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(0);
        make.right.mas_offset(0);
        make.centerY.mas_offset(0);
        make.height.offset(35);
    }];
}
@end
